package com.cat.binaryAnswer;

/**
*   @description https://leetcode.cn/problems/h-index-ii/description/
*   @author 曲大人的喵
*   @create 2025/8/11 16:10
*   @since JDK17
*/

public class Solution09 {
    public int hIndex(int[] citations) {
        int l = 0, n = citations.length, r = n, mid;
        while (l + 1 < r) {
            mid = l + (r - l) / 2;
            if (citations[mid] >= n - mid) {
                r = mid;
            } else {
                l = mid;
            }
        }
        return r;
    }
}
